package com.xm.httpapi.Aspect;

import com.xm.httpapi.BaseUtils.Toast;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
/**
 * Author:guohaijin
 * Date:
 * Description:
 */
@Aspect
public class ErrorAspect {
    private static final String POINTCUT_METHOD = "execution(@com.xm.httpapi.Annotation.Error * *(..))";


    @Around("onErrorMethod()")
    public void doErrorMethod(final ProceedingJoinPoint joinPoint) throws Throwable {
        errorMethod(joinPoint);
    }

    @Pointcut(POINTCUT_METHOD)
    public void onErrorMethod() {
    }

    private void errorMethod(final ProceedingJoinPoint joinPoint) throws Throwable {
        try {
            joinPoint.proceed();
        } catch (Exception e) {
            Toast.show(e.getMessage());
        }

    }
}
